package com.bbcare.img.plat.service.impl;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import com.bbcare.comm.*;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.shiro.util.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;

import com.bbcare.img.plat.entity.AiEquip;
import com.bbcare.img.plat.entity.AiEquipFileRule;
import com.bbcare.img.plat.entity.AiImg;
import com.bbcare.img.plat.entity.AiImgData;
import com.bbcare.img.plat.entity.AiProgram;
import com.bbcare.img.plat.service.IClientImgDealService;
import com.bbcare.img.plat.store.ibatis.IEquipDAO;
import com.bbcare.img.plat.store.ibatis.IEquipFileRuleDAO;
import com.bbcare.img.plat.store.ibatis.IIaOperationRecordDAO;
import com.bbcare.img.plat.store.ibatis.IImgDAO;
import com.bbcare.img.plat.store.ibatis.IImgDataDAO;
import com.bbcare.img.plat.store.ibatis.IProgramDAO;

/**
 * @name: 客户端影像文件处理服务接口实现
 * @author: DemonLee
 * @createTime: 2017.10.30
 * @description: 客户端影像文件上传等
 * @modify:
 *
 */
@Service
public class ClientImgDealServiceImpl implements IClientImgDealService {
    private final Log logger = LogFactory.getLog(ClientImgDealServiceImpl.class);

    @Autowired
    private IEquipDAO equipDao;

    @Autowired
    private IProgramDAO programDao;

    @Autowired
    private IIaOperationRecordDAO iaOperationRecordDao;

    @Autowired
    private IImgDAO imgDao;

    @Autowired
    private IEquipFileRuleDAO equipFileRuleDao;

    @Autowired
    private IImgDataDAO imgDataDao;

    // 客户端影像文件上传接口实现（单个文件）
    @Transactional
    public Map<String, Object> uploadClientImg(Map<String, Object> mapIn, MultipartHttpServletRequest multiRequest)
            throws Exception {
        Map<String, Object> argMap = new HashMap<String, Object>(mapIn);
        Map<String, Object> outMap = new HashMap<String, Object>();
        Map<String, Object> oprInfo = ToolUtil.typeCast(argMap.get("oprInfo"));
        Map<String, Object> fileInfo = ToolUtil.typeCast(argMap.get("fileInfo"));
        Map<String, Object> sessionInfo = ToolUtil.typeCast(mapIn.get("sessionInfo"));// 客户端上传无此节点
        Map<String, Object> userInfo = ToolUtil.typeCast(argMap.get("userInfo"));// 客户端上传无此节点
        String updateTime = (String) oprInfo.get("updateTime");
        String updateAccept = (String) oprInfo.get("updateAccept");
        String uploadType = (String) oprInfo.get("uploadType");

        // 根据小程序注册id校验小程序信息
        Map<String, Object> checkMapOut = this.checkEquipProgram(argMap);
        String tenantId = (String) checkMapOut.get("tenantId");
        fileInfo.put("classId", (String) checkMapOut.get("classId"));
        fileInfo.put("tenantId", tenantId);
        fileInfo.put("equipId", (String) checkMapOut.get("equipId"));
        oprInfo.put("programId", (String) checkMapOut.get("programId"));

        // 上传文件
        outMap = this.uploadFile(argMap, multiRequest);

        String opUser = "";
        String userId = "";
        String opUsertype = "";
        if (Constants.FILE_UPLOAD_TYPE_FOR_BACKGROUND_PROGRAM.equals(uploadType)) {
            opUser = Constants.BG_LOGIN_NO_ADMIN_FOR_IMG;
            opUsertype = Constants.OPCODE_TYPE_BG_ADMIN;
        } else if (MapUtils.isNotEmpty(sessionInfo)) {
            opUser = (String) sessionInfo.get("authorId");
            opUsertype = Constants.OPCODE_TYPE_DOCTOR;
        }
        if (MapUtils.isNotEmpty(userInfo)) {
            userId = (String) userInfo.get("userId");
        }
        // 操作记录
        Map<String, Object> paramRecord = new HashMap<String, Object>();
        Calendar now = Calendar.getInstance();
        paramRecord.put("month", String.valueOf(now.get(Calendar.MONTH) + 1));
        paramRecord.put("day", String.valueOf(now.get(Calendar.DAY_OF_MONTH)));
        paramRecord.put("userId", userId);
        paramRecord.put("queueId", "");
        paramRecord.put("opUser", opUser);
        paramRecord.put("opTime", updateTime);
        paramRecord.put("remark", oprInfo.get("opNote"));
        paramRecord.put("busiCategory", Constants.DOCTOR_ACTIVE_BUSI_TYPE_10);
        paramRecord.put("opUsertype", opUsertype);
        paramRecord.put("id", updateAccept);
        paramRecord.put("opDesc", oprInfo.get("opNote"));
        paramRecord.put("opCode", oprInfo.get("opCode"));
        paramRecord.put("busiId", null);
        paramRecord.put("tenantId", tenantId);
        paramRecord.put("opType", oprInfo.get("opType"));
        paramRecord.put("taskId", "");
        paramRecord.put("breifIntro", outMap.toString());
        iaOperationRecordDao.saveOperationRecord(paramRecord);

        // 客户端小程序上传不返回数据
        if (Constants.FILE_UPLOAD_TYPE_FOR_BACKGROUND_PROGRAM.equals(uploadType)) {
            outMap.clear();
        }

        return outMap;
    }

    // 客户端影像文件上传接口实现（多个文件）
    @Transactional
    public Map<String, Object> uploadMultiClientImg(Map<String, Object> mapIn, MultipartHttpServletRequest multiRequest)
            throws Exception {
        Map<String, Object> argMap = new HashMap<String, Object>(mapIn);
        Map<String, Object> outMap = new HashMap<String, Object>();
        Map<String, Object> oprInfo = ToolUtil.typeCast(argMap.get("oprInfo"));
        Map<String, Object> sessionInfo = ToolUtil.typeCast(mapIn.get("sessionInfo"));// 客户端上传无此节点
        Map<String, Object> userInfo = ToolUtil.typeCast(argMap.get("userInfo"));// 客户端上传无此节点
        String updateTime = (String) oprInfo.get("updateTime");
        String updateAccept = (String) oprInfo.get("updateAccept");
        String uploadType = (String) oprInfo.get("uploadType");

        // 上传文件
        outMap = this.uploadMultiFile(argMap, multiRequest);

        String opUser = "";
        String userId = "";
        String opUsertype = "";
        if (Constants.FILE_UPLOAD_TYPE_FOR_BACKGROUND_PROGRAM.equals(uploadType)) {
            opUser = Constants.BG_LOGIN_NO_ADMIN_FOR_IMG;
            opUsertype = Constants.OPCODE_TYPE_BG_ADMIN;
        } else if (MapUtils.isNotEmpty(sessionInfo)) {
            opUser = (String) sessionInfo.get("authorId");
            opUsertype = Constants.OPCODE_TYPE_DOCTOR;
        }
        if (MapUtils.isNotEmpty(userInfo)) {
            userId = (String) userInfo.get("userId");
        }
        // 操作记录
        Map<String, Object> paramRecord = new HashMap<String, Object>();
        Calendar now = Calendar.getInstance();
        paramRecord.put("month", String.valueOf(now.get(Calendar.MONTH) + 1));
        paramRecord.put("day", String.valueOf(now.get(Calendar.DAY_OF_MONTH)));
        paramRecord.put("userId", userId);
        paramRecord.put("queueId", "");
        paramRecord.put("opUser", opUser);
        paramRecord.put("opTime", updateTime);
        paramRecord.put("remark", oprInfo.get("opNote"));
        paramRecord.put("busiCategory", Constants.DOCTOR_ACTIVE_BUSI_TYPE_10);
        paramRecord.put("opUsertype", opUsertype);
        paramRecord.put("id", updateAccept);
        paramRecord.put("opDesc", oprInfo.get("opNote"));
        paramRecord.put("opCode", oprInfo.get("opCode"));
        paramRecord.put("busiId", null);
        paramRecord.put("tenantId", outMap.get("tenantId"));
        paramRecord.put("opType", oprInfo.get("opType"));
        paramRecord.put("taskId", "");
        outMap.remove("tenantId");
        paramRecord.put("breifIntro", outMap.toString());
        iaOperationRecordDao.saveOperationRecord(paramRecord);

        // 客户端小程序上传不返回数据
        if (Constants.FILE_UPLOAD_TYPE_FOR_BACKGROUND_PROGRAM.equals(uploadType)) {
            outMap.clear();
        }

        return outMap;
    }

    // 校验相关信息（如小程序，设备等）
    public Map<String, Object> checkEquipProgram(Map<String, Object> mapIn) throws Exception {
        Map<String, Object> mapOut = new HashMap<String, Object>();
        Map<String, Object> oprInfo = ToolUtil.typeCast(mapIn.get("oprInfo"));
        Map<String, Object> sessionInfo = ToolUtil.typeCast(mapIn.get("sessionInfo"));
        Map<String, Object> fileInfo = ToolUtil.typeCast(mapIn.get("fileInfo"));
        String uploadType = (String) oprInfo.get("uploadType");

        Map<String, Object> qryMapIn = new HashMap<String, Object>();
        AiEquip aiEquipVo = new AiEquip();
        String tenantId = "";
        String programId = "";
        String classId = "";
        String equipId = "";
        // 客户端小程序上传
        if (Constants.FILE_UPLOAD_TYPE_FOR_BACKGROUND_PROGRAM.equals(uploadType)) {
            // 根据小程序注册id校验小程序信息
            programId = (String) oprInfo.get("programId");
            qryMapIn.put("id", programId);
            qryMapIn.put("status", Constants.TABLE_RECORD_STATUS_NOMAL);
            List<AiProgram> progList = programDao.listProgramByCondition(qryMapIn);
            if (CollectionUtils.isEmpty(progList)) {
                throw (new AppException(ErrorCode.IMG_EXCEPTION_PROGRAM_NOT_EXISTS, "根据程序id未查询到对应注册信息，上传文件失败！"));
            }

            // 根据小程序注册id获取设备信息
            qryMapIn.remove("id");
            qryMapIn.put("programId", programId);
            List<AiEquip> equipList = equipDao.listEquipByCondition(qryMapIn);
            if (CollectionUtils.isEmpty(equipList)) {
                throw (new AppException(ErrorCode.IMG_EXCEPTION_EQUIP_NOT_EXISTS, "根据程序id未查询到绑定的设备信息，上传文件失败！"));
            } else if (1 != equipList.size()) {
                throw (new AppException(ErrorCode.IMG_EXCEPTION_PROGRAMID_BIND_MULTIEQUIP, "一个程序id绑定了多台设备信息，上传文件失败！"));
            }
            aiEquipVo = equipList.get(0);
            tenantId = aiEquipVo.getTenantId();
            if (StringUtils.isBlank(tenantId)) {
                throw (new AppException(ErrorCode.IMG_EXCEPTION_TENANTID_ISNULL, "获取租户id为空，上传文件失败！"));
            }
            classId = aiEquipVo.getClassId();
            equipId = aiEquipVo.getId();
        } else if (Constants.FILE_UPLOAD_TYPE_FOR_MANUAL.equals(uploadType)) {
            // web端手动上传
            equipId = (String) oprInfo.get("equipId");
            tenantId = (String) sessionInfo.get("tenantId");
            String equipFlag = (String) oprInfo.get("equipFlag");
            if (Constants.FILE_UPLOAD_EQUIP_TYPE_FOR_REAL.equals(equipFlag)) {
                // 根据设备id获取设备信息
                qryMapIn.clear();
                qryMapIn.put("id", equipId);
                qryMapIn.put("tenantId", tenantId);
                qryMapIn.put("status", Constants.TABLE_RECORD_STATUS_NOMAL);
                List<AiEquip> equipList = equipDao.listEquipByCondition(qryMapIn);
                if (CollectionUtils.isEmpty(equipList)) {
                    throw (new AppException(ErrorCode.IMG_EXCEPTION_EQUIP_NOT_EXISTS, "根据设备id未查询到当前租户下的设备信息，上传文件失败！"));
                }
                aiEquipVo = equipList.get(0);
                programId = aiEquipVo.getProgramId();
                classId = aiEquipVo.getClassId();
            } else if (Constants.FILE_UPLOAD_EQUIP_TYPE_FOR_VIRTUAL.equals(equipFlag)) {
                // 手动上传虚拟设备
                programId = Constants.PROGRAM_ID_FOR_VIRTUAL_EQUIP_MANUAL;
                classId = Constants.CLASS_ID_FOR_VIRTUAL_EQUIP_MANUAL;
            } else {
                // 后续可能还有拍照上传
            }
        } else if (Constants.FILE_UPLOAD_TYPE_FOR_CLIP.equals(uploadType)) {
            // web端裁剪后手动上传
            qryMapIn.clear();
            tenantId = (String) sessionInfo.get("tenantId");
            String imgId = (String) fileInfo.get("imgId");
            qryMapIn.put("id", imgId);
            qryMapIn.put("status", Constants.TABLE_RECORD_STATUS_NOMAL);
            qryMapIn.put("tenantId", tenantId);
            List<AiImg> imgList = imgDao.listImgByCondition(qryMapIn);
            if (CollectionUtils.isEmpty(imgList)) {
                throw (new AppException(ErrorCode.IMG_EXCEPTION_IMG_NOT_EXISTS, "根据文件id未查询到当前租户下的文件信息，上传文件失败！"));
            }
            AiImg imgVo = imgList.get(0);
            programId = imgVo.getProgramId();
            classId = imgVo.getClassId();
            equipId = imgVo.getEquipId();
        } else if(Constants.FILE_UPLOAD_TYPE_FOR_USER.equals(uploadType)){
        	// web端手动上传
            equipId = (String) oprInfo.get("equipId");
            tenantId = (String) sessionInfo.get("tenantId");
            String equipFlag = (String) oprInfo.get("equipFlag");
          if (Constants.FILE_UPLOAD_EQUIP_TYPE_FOR_VIRTUAL.equals(equipFlag)) {
                // 手动上传虚拟设备
                programId = Constants.PROGRAM_ID_FOR_VIRTUAL_EQUIP_MANUAL;
                classId = Constants.CLASS_ID_FOR_VIRTUAL_EQUIP_MANUAL;
            } else {
                // 后续可能还有拍照上传
            }
        }else {
            // 其他暂不支持
            throw (new AppException(ErrorCode.IMG_EXCEPTION_IMG_UPLOADTYPE_NOT_SUPPORT, "暂不支持该类上传方式，上传文件失败！"));
        }
        mapOut.put("tenantId", tenantId);
        mapOut.put("classId", classId);
        mapOut.put("equipId", equipId);
        mapOut.put("programId", programId);

        return mapOut;
    }

    // 上传文件
    public Map<String, Object> uploadMultiFile(Map<String, Object> mapIn, MultipartHttpServletRequest multiRequest)
            throws Exception {
        Map<String, Object> argMap = new HashMap<String, Object>(mapIn);
        Map<String, Object> outMap = new HashMap<String, Object>();
        List<Map<String, Object>> fileList = ToolUtil.typeCast(argMap.get("fileList"));
        Map<String, Object> oprInfo = ToolUtil.typeCast(argMap.get("oprInfo"));
        String uploadType = (String) oprInfo.get("uploadType");

        // 逐个文件处理
        String uploadPath = "";
        String tenantId = "";
        List<Object> imgPathList = new ArrayList<Object>();
        Iterator<String> iter = multiRequest.getFileNames();
        if (iter.hasNext()) {
            Map<String, Object> uploadMapOut = new HashMap<String, Object>();
            int fileNum = 0;
            argMap.remove("fileList");
            while (iter.hasNext()) {
                // 根据小程序注册id校验小程序信息
                Map<String, Object> fileInfo = fileList.get(fileNum);
                argMap.put("fileInfo", fileInfo);
                Map<String, Object> checkMapOut = this.checkEquipProgram(argMap);
                tenantId = (String) checkMapOut.get("tenantId");
                fileInfo.put("classId", (String) checkMapOut.get("classId"));
                fileInfo.put("tenantId", tenantId);
                fileInfo.put("equipId", (String) checkMapOut.get("equipId"));
                oprInfo.put("programId", (String) checkMapOut.get("programId"));

                // 文件上传路径：基础路径+租户id
                if (StringUtils.isBlank(uploadPath)) {
                    uploadPath = ToolUtil.getUploadFilePath(Constants.FILE_UPLOAD_FOR_IMG_BASIC_PATH_ID_NAME, tenantId);
                }
                uploadMapOut.clear();
                MultipartFile file = multiRequest.getFile(iter.next());
                if (!file.isEmpty()) {
                    // 上传处理
                    OSSClientUtil.uploadPicture(file, uploadPath, fileInfo,false);

                    // 入文件信息表
                    Map<String, Object> saveMapOut = new HashMap<String, Object>();
                    if (Constants.FILE_UPLOAD_TYPE_FOR_CLIP.equals(uploadType)) {
                        saveMapOut = this.saveClipImgInfo(argMap);
                    } else {
                        saveMapOut = this.saveImgInfo(argMap);
                    }
                    imgPathList.add(saveMapOut);
                }
                fileNum++;
            }
        }
        outMap.put("imgList", imgPathList);
        outMap.put("tenantId", tenantId);

        return outMap;
    }

    // 上传文件
    public Map<String, Object> uploadFile(Map<String, Object> mapIn, MultipartHttpServletRequest multiRequest)
            throws Exception {
        Map<String, Object> argMap = new HashMap<String, Object>(mapIn);
        Map<String, Object> outMap = new HashMap<String, Object>();
        Map<String, Object> fileInfo = ToolUtil.typeCast(argMap.get("fileInfo"));
        Map<String, Object> oprInfo = ToolUtil.typeCast(argMap.get("oprInfo"));
        String tenantId = (String) fileInfo.get("tenantId");
        String uploadType = (String) oprInfo.get("uploadType");

        // 文件上传路径：基础路径+租户id
        String uploadPath = ToolUtil.getUploadFilePath(Constants.FILE_UPLOAD_FOR_IMG_BASIC_PATH_ID_NAME, tenantId);

        // 逐个文件处理
        List<Object> imgPathList = new ArrayList<Object>();
        Iterator<String> iter = multiRequest.getFileNames();
        if (iter.hasNext()) {
            Map<String, Object> uploadMapOut = new HashMap<String, Object>();
            while (iter.hasNext()) {
                uploadMapOut.clear();
                MultipartFile file = multiRequest.getFile(iter.next());
                if (!file.isEmpty()) {
                    // 上传处理
                    OSSClientUtil.uploadPicture(file, uploadPath, fileInfo,false);

                    // 入文件信息表
                    Map<String, Object> saveMapOut = new HashMap<String, Object>();
                    if (Constants.FILE_UPLOAD_TYPE_FOR_CLIP.equals(uploadType)) {
                        saveMapOut = this.saveClipImgInfo(argMap);
                    } else {
                        saveMapOut = this.saveImgInfo(argMap);
                    }
                    imgPathList.add(saveMapOut);
                }
            }
        }
        outMap.put("imgList", imgPathList);

        return outMap;
    }

    // 文件信息入表处理
    public Map<String, Object> saveImgInfo(Map<String, Object> mapIn) throws Exception {
        logger.info("saveImgInfo mapIn==" + mapIn);
        Map<String, Object> argMap = new HashMap<String, Object>(mapIn);
        Map<String, Object> outMap = new HashMap<String, Object>();
        Map<String, Object> oprInfo = ToolUtil.typeCast(argMap.get("oprInfo"));
        Map<String, Object> fileInfo = ToolUtil.typeCast(argMap.get("fileInfo"));
        Map<String, Object> userInfo = ToolUtil.typeCast(argMap.get("userInfo"));// 客户端上传无此节点
        Map<String, Object> sessionInfo = ToolUtil.typeCast(mapIn.get("sessionInfo"));
        String programId = (String) oprInfo.get("programId");
        String updateTime = (String) oprInfo.get("updateTime");
        String updateAccept = (String) oprInfo.get("updateAccept");
        String uploadType = (String) oprInfo.get("uploadType");
        String authorId = "";
        if (Constants.FILE_UPLOAD_TYPE_FOR_BACKGROUND_PROGRAM.equals(uploadType)) {
            authorId = Constants.BG_LOGIN_NO_ADMIN_FOR_IMG;
        } else if (MapUtils.isNotEmpty(sessionInfo)) {
            authorId = (String) sessionInfo.get("authorId");
        }

        // 文件id
        String imgId = SeqUtil.getSeqNo(Constants.SEQ_NO_FOR_IMG_ID);
        fileInfo.put("imgId", imgId);

        // 解析原文件名，根据配置规则获取一些患者基本信息
        String birthday = null;
        String gender = null;
        String residentAddress = null;
        String userId = null;
        String queueId = null;
        Map<String, Object> parseMapOut = this.DealFileName(argMap);
        String hisNo = (String) parseMapOut.get("hisNo");
        String fileUserName = (String) parseMapOut.get("fileUserName");
        if (MapUtils.isNotEmpty(userInfo)) {
            if (StringUtils.isBlank(hisNo)) {
                hisNo = (String) userInfo.get("hisNo");
            }
            birthday = (String) userInfo.get("birthday");
            gender = (String) userInfo.get("gender");
            residentAddress = (String) userInfo.get("residentAddress");
            userId = (String) userInfo.get("userId");
            queueId= (String)userInfo.get("queueId");
        }

        // 文件信息入表
        AiImg imgVo = new AiImg();
        imgVo.setBirthday(birthday);
        imgVo.setClassId((String) fileInfo.get("classId"));
        imgVo.setCreateAuthor(authorId);
        imgVo.setEquipId((String) fileInfo.get("equipId"));
        imgVo.setFileAuthorName((String) fileInfo.get("fileAuthorName"));
        imgVo.setFileCreateTime((String) fileInfo.get("fileCreateTime"));
        imgVo.setFileModifyTime((String) fileInfo.get("fileModifyTime"));
        imgVo.setFileName((String) fileInfo.get("fileName"));
        imgVo.setFilePath((String) fileInfo.get("filePath"));
        imgVo.setFileSize((Long) fileInfo.get("fileSize"));
        imgVo.setFileType((String) fileInfo.get("fileType"));
        imgVo.setGender(gender);
        imgVo.setHisNo(hisNo);
        imgVo.setId(imgId);
        imgVo.setInsideIp((String) fileInfo.get("insideIp"));
        imgVo.setOpTime(updateTime);
        imgVo.setOutsideIp((String) fileInfo.get("outsideIp"));
        imgVo.setProgramId(programId);
        imgVo.setResidentAddress(residentAddress);
        imgVo.setSourceFileId("");
        imgVo.setSourceFileName((String) fileInfo.get("sourceFileName"));
        imgVo.setStatus(Constants.TABLE_RECORD_STATUS_NOMAL);
        imgVo.setTenantId((String) fileInfo.get("tenantId"));
        imgVo.setUpdateAccept(updateAccept);
        imgVo.setUpdateAuthor(authorId);
        imgVo.setUpdateTime(updateTime);
        imgVo.setUploadType(uploadType);
        imgVo.setUserId(userId);
        imgVo.setSourceFilePath((String) fileInfo.get("sourceFilePath"));
        imgVo.setFileUserName(fileUserName);
        imgVo.setRotationAngle(Constants.IMG_FILE_DEFAULT_ROTATION_ANGLE);
        imgVo.setSourceQueueId(queueId);
        imgDao.saveAiImg(imgVo);
        // 入文件历史表
        Map<String, Object> hisMap = new HashMap<String, Object>();
        hisMap.put("id", imgId);
        hisMap.put("updateTime", updateTime);
        hisMap.put("updateAccept", updateAccept);
        hisMap.put("updateType", Constants.UPDATE_TYPE_INSERT);
        imgDao.saveAiImgHis(hisMap);

        outMap.put("imgId", imgId);
        outMap.put("imagePath", fileInfo.get("filePath"));
        outMap.put("fileName", fileInfo.get("fileName"));
        outMap.put("sourceFileName", fileInfo.get("sourceFileName"));
        return outMap;
    }

    // 文件名解析并入文件详情表
    public Map<String, Object> DealFileName(Map<String, Object> mapIn) throws Exception {
        Map<String, Object> argMap = new HashMap<String, Object>(mapIn);
        Map<String, Object> outMap = new HashMap<String, Object>();
        Map<String, Object> oprInfo = ToolUtil.typeCast(argMap.get("oprInfo"));
        Map<String, Object> fileInfo = ToolUtil.typeCast(argMap.get("fileInfo"));
        Map<String, Object> userInfo = ToolUtil.typeCast(argMap.get("userInfo"));
        Map<String, Object> sessionInfo = ToolUtil.typeCast(mapIn.get("sessionInfo"));
        String classId = (String) fileInfo.get("classId");
        String sourceFileName = (String) fileInfo.get("sourceFileName");
        String updateTime = (String) oprInfo.get("updateTime");
        String uploadType = (String) oprInfo.get("uploadType");
        String authorId = "";
        if (Constants.FILE_UPLOAD_TYPE_FOR_BACKGROUND_PROGRAM.equals(uploadType)) {
            authorId = Constants.BG_LOGIN_NO_ADMIN_FOR_IMG;
        } else if (MapUtils.isNotEmpty(sessionInfo)) {
            authorId = (String) sessionInfo.get("authorId");
        }
        String userId = null;
        if (MapUtils.isNotEmpty(userInfo)) {
            userId = (String) userInfo.get("userId");
        }
        String tenantId = (String) fileInfo.get("tenantId");

        // 根据设备分类查询设备命名规则配置
        Map<String, Object> dealMapIn = new HashMap<String, Object>();
        dealMapIn.put("status", Constants.TABLE_RECORD_STATUS_NOMAL);
        dealMapIn.put("classId", classId);
        dealMapIn.put("tenantId", tenantId);
        List<AiEquipFileRule> efrList = equipFileRuleDao.listEquipFileRuleByCondition(dealMapIn);
        if (CollectionUtils.isEmpty(efrList)) {
            return outMap;
        }

        // 去掉文件扩展名
        int endPos = sourceFileName.lastIndexOf(".");
        if (-1 == endPos) {
            endPos = sourceFileName.length();
        }
        String oriFileName = sourceFileName.substring(0, endPos);
        dealMapIn.put("sourceFileName", oriFileName);
        dealMapIn.put("sourceFilePath", (String) fileInfo.get("sourceFilePath"));

        // 按照规则逐个解析
        Map<String, Object> dealMap = this.DealFileRuleList(dealMapIn);
        outMap = ToolUtil.typeCast(dealMap.get("outDataMap"));
        Map<String, Object> ruleDataOut = ToolUtil.typeCast(dealMap.get("ruleDataMap"));

        // 批量入文件详情表
        if (MapUtils.isNotEmpty(outMap)) {
            List<AiImgData> imgDataList = new ArrayList<AiImgData>();
            Iterator<String> iter = outMap.keySet().iterator();
            String key = "";
            while (iter.hasNext()) {
                key = iter.next();
                AiImgData imgData = new AiImgData();
                imgData.setCreateAuthor(authorId);
                imgData.setCreateTime(updateTime);
                imgData.setDataName(key);
                imgData.setDataValue((String) outMap.get(key));
                imgData.setEquipId((String) fileInfo.get("equipId"));
                imgData.setId(SeqUtil.getSeqNo(Constants.SEQ_NO_FOR_IMG_DATA_ID));
                imgData.setImgId((String) fileInfo.get("imgId"));
                imgData.setProgramId((String) oprInfo.get("programId"));
                imgData.setRuleId((String) ruleDataOut.get(key));
                imgData.setStatus(Constants.TABLE_RECORD_STATUS_NOMAL);
                imgData.setTenantId(tenantId);
                imgData.setUpdateAccept((String) oprInfo.get("updateAccept"));
                imgData.setUpdateAuthor(authorId);
                imgData.setUpdateTime(updateTime);
                imgData.setUpdateType(Constants.UPDATE_TYPE_INSERT);
                imgData.setUserId(userId);

                imgDataList.add(imgData);
            }
            imgDataDao.saveAiImgDataBatch(imgDataList);
            imgDataDao.saveAiImgDataHisBatch(imgDataList);
        }

        return outMap;
    }

    // 规则逐个解析
    public Map<String, Object> DealFileRuleList(Map<String, Object> mapIn) throws Exception {
        Map<String, Object> outMap = new HashMap<String, Object>();
        Map<String, Object> ruleDataMap = new HashMap<String, Object>();
        Map<String, Object> outDataMap = new HashMap<String, Object>();
        AiEquipFileRule equipFileRule = new AiEquipFileRule();
        String sourceFileName = (String) mapIn.get("sourceFileName");
        String sourceFilePath = (String) mapIn.get("sourceFilePath");

        // 规则查询
        Map<String, Object> dealMapIn = new HashMap<String, Object>();
        dealMapIn.put("status", Constants.TABLE_RECORD_STATUS_NOMAL);
        dealMapIn.put("classId", mapIn.get("classId"));
        dealMapIn.put("tenantId", mapIn.get("tenantId"));
        dealMapIn.put("ruleType", Constants.IMG_FILE_RULE_TYPE_FOR_FILENAME);// 文件名规则
        List<AiEquipFileRule> efrList = equipFileRuleDao.listEquipFileRuleByCondition(dealMapIn);

        String parseValue = "";
        int r = 0;
        int rsize = 0;
        // 文件名规则解析
        if (!CollectionUtils.isEmpty(efrList)) {
            rsize = efrList.size();
            for (r = 0; r < rsize; r++) {
                equipFileRule = efrList.get(r);
                parseValue = this.parseFileName(equipFileRule, sourceFileName);
                if (StringUtils.isNotBlank(parseValue)) {
                    outDataMap.put(equipFileRule.getRuleName(), parseValue);
                    ruleDataMap.put(equipFileRule.getRuleName(), equipFileRule.getId());
                }
            }
        }

        if (StringUtils.isNotBlank(sourceFilePath)) {
            dealMapIn.put("ruleType", Constants.IMG_FILE_RULE_TYPE_FOR_FILEPATH);// 文件路径规则
            efrList = equipFileRuleDao.listEquipFileRuleByCondition(dealMapIn);
            // 文件路径规则解析
            if (!CollectionUtils.isEmpty(efrList)) {
                rsize = efrList.size();
                for (r = 0; r < rsize; r++) {
                    equipFileRule = efrList.get(r);
                    parseValue = this.parseFilePath(equipFileRule, sourceFilePath);
                    if (StringUtils.isNotBlank(parseValue)) {
                        outDataMap.put(equipFileRule.getRuleName(), parseValue);
                        ruleDataMap.put(equipFileRule.getRuleName(), equipFileRule.getId());
                    }
                }
            }
        }

        outMap.put("outDataMap", outDataMap);
        outMap.put("ruleDataMap", ruleDataMap);

        return outMap;
    }

    // 解析文件名
    public String parseFileName(AiEquipFileRule equipFileRule, String sourceFileName) throws Exception {
        String rulePrefix = equipFileRule.getRulePrefix();
        String ruleSuffix = equipFileRule.getRuleSuffix();
        Integer beginIndex = equipFileRule.getBeginIndex();
        int seqNo = equipFileRule.getSeqNo();

        // 目前具体规则还没有
        if (StringUtils.isBlank(rulePrefix) && StringUtils.isBlank(ruleSuffix) && 0 == beginIndex && 0 == seqNo) {
            // 全文件名作为变量的值
            return sourceFileName;
        }

        return null;
    }

    // 解析文件名
    public String parseFilePath(AiEquipFileRule equipFileRule, String sourceFilePath) throws Exception {
        Integer beginIndex = equipFileRule.getBeginIndex();
        logger.info("sourceFilePath==" + sourceFilePath);
        String[] filePathArr = sourceFilePath.split(Constants.BACKSLASH_STR);
        // 具体规则待定，默认取每个文件夹的名称
        if (null != beginIndex && beginIndex < filePathArr.length) {
            return filePathArr[beginIndex];
        }

        return null;
    }

    // 裁剪文件信息入表处理
    public Map<String, Object> saveClipImgInfo(Map<String, Object> mapIn) throws Exception {
        logger.info("saveImgInfo mapIn==" + mapIn);
        Map<String, Object> argMap = new HashMap<String, Object>(mapIn);
        Map<String, Object> outMap = new HashMap<String, Object>();
        Map<String, Object> oprInfo = ToolUtil.typeCast(argMap.get("oprInfo"));
        Map<String, Object> fileInfo = ToolUtil.typeCast(argMap.get("fileInfo"));
        Map<String, Object> sessionInfo = ToolUtil.typeCast(mapIn.get("sessionInfo"));
        String updateTime = (String) oprInfo.get("updateTime");
        String updateAccept = (String) oprInfo.get("updateAccept");
        String uploadType = (String) oprInfo.get("uploadType");
        String tenantId = (String) fileInfo.get("tenantId");
        String authorId = (String) sessionInfo.get("authorId");
        String oldImgId = (String) fileInfo.get("imgId");// 原始文件id
        String imgId = SeqUtil.getSeqNo(Constants.SEQ_NO_FOR_IMG_ID);// 新文件id

        // 文件扩展信息复制
        fileInfo.put("newImgId", imgId);
        this.saveClipImgDataInfo(mapIn);

        // 文件信息复制
        Map<String, Object> qryMapIn = new HashMap<String, Object>();
        qryMapIn.put("id", oldImgId);
        qryMapIn.put("status", Constants.TABLE_RECORD_STATUS_NOMAL);
        qryMapIn.put("tenantId", tenantId);
        List<AiImg> imgList = imgDao.listImgByCondition(qryMapIn);
        if (CollectionUtils.isEmpty(imgList)) {
            throw (new AppException(ErrorCode.IMG_EXCEPTION_IMG_NOT_EXISTS, "根据文件id未查询到当前租户下的文件信息，上传文件失败！"));
        }
        AiImg oldImgVo = imgList.get(0);
        AiImg imgVo = new AiImg();
        imgVo.setBirthday(oldImgVo.getBirthday());
        imgVo.setClassId(oldImgVo.getClassId());
        imgVo.setCreateAuthor(authorId);
        imgVo.setEquipId(oldImgVo.getEquipId());
        imgVo.setFileAuthorName(oldImgVo.getFileAuthorName());
        imgVo.setFileCreateTime(updateTime);
        imgVo.setFileModifyTime(updateTime);
        imgVo.setFileName((String) fileInfo.get("fileName"));
        imgVo.setFilePath((String) fileInfo.get("filePath"));
        imgVo.setFileSize((Long) fileInfo.get("fileSize"));
        imgVo.setFileType((String) fileInfo.get("fileType"));
        imgVo.setGender(oldImgVo.getGender());
        imgVo.setHisNo(oldImgVo.getHisNo());
        imgVo.setId(imgId);
        imgVo.setInsideIp(oldImgVo.getInsideIp());
        imgVo.setOpTime(updateTime);
        imgVo.setOutsideIp(oldImgVo.getOutsideIp());
        imgVo.setProgramId(oldImgVo.getProgramId());
        imgVo.setResidentAddress(oldImgVo.getResidentAddress());
        imgVo.setSourceFileId(oldImgId);
        imgVo.setSourceFileName((String) fileInfo.get("sourceFileName"));
        imgVo.setStatus(Constants.TABLE_RECORD_STATUS_NOMAL);
        imgVo.setTenantId(tenantId);
        imgVo.setUpdateAccept(updateAccept);
        imgVo.setUpdateAuthor(authorId);
        imgVo.setUpdateTime(updateTime);
        imgVo.setUploadType(uploadType);
        imgVo.setUserId(oldImgVo.getUserId());
        imgVo.setSourceFilePath(oldImgVo.getSourceFilePath());
        imgVo.setFileUserName(oldImgVo.getFileUserName());
        imgVo.setRotationAngle(Constants.IMG_FILE_DEFAULT_ROTATION_ANGLE);
        imgDao.saveAiImg(imgVo);
        // 入文件历史表
        Map<String, Object> hisMap = new HashMap<String, Object>();
        hisMap.put("id", imgId);
        hisMap.put("updateTime", updateTime);
        hisMap.put("updateAccept", updateAccept);
        hisMap.put("updateType", Constants.UPDATE_TYPE_INSERT);
        imgDao.saveAiImgHis(hisMap);

        outMap.put("imgId", imgId);
        outMap.put("imagePath", fileInfo.get("filePath"));
        outMap.put("fileName", fileInfo.get("fileName"));
        outMap.put("sourceFileName", fileInfo.get("sourceFileName"));
        return outMap;
    }

    // 文件名称解析并入文件详情表
    public Map<String, Object> saveClipImgDataInfo(Map<String, Object> mapIn) throws Exception {
        Map<String, Object> argMap = new HashMap<String, Object>(mapIn);
        Map<String, Object> outMap = new HashMap<String, Object>();
        Map<String, Object> oprInfo = ToolUtil.typeCast(argMap.get("oprInfo"));
        Map<String, Object> fileInfo = ToolUtil.typeCast(argMap.get("fileInfo"));
        Map<String, Object> sessionInfo = ToolUtil.typeCast(mapIn.get("sessionInfo"));
        String updateTime = (String) oprInfo.get("updateTime");
        String authorId = (String) sessionInfo.get("authorId");
        String oldImgId = (String) fileInfo.get("imgId");// 原始文件id
        String newImgId = (String) fileInfo.get("newImgId");// 新文件id

        // 查询扩展信息
        Map<String, Object> qryMapIn = new HashMap<String, Object>();
        qryMapIn.put("imgId", oldImgId);
        qryMapIn.put("status", Constants.TABLE_RECORD_STATUS_NOMAL);
        List<AiImgData> oldImgDataList = imgDataDao.listImgDataByCondition(qryMapIn);
        if (CollectionUtils.isEmpty(oldImgDataList)) {
            return outMap;
        }

        // 批量入文件详情表
        List<AiImgData> imgDataList = new ArrayList<AiImgData>();
        int i = 0;
        int isize = oldImgDataList.size();
        for (i = 0; i < isize; i++) {
            AiImgData oldImgData = oldImgDataList.get(i);
            AiImgData imgData = new AiImgData();
            imgData.setCreateAuthor(authorId);
            imgData.setCreateTime(updateTime);
            imgData.setDataName(oldImgData.getDataName());
            imgData.setDataValue(oldImgData.getDataValue());
            imgData.setEquipId(oldImgData.getEquipId());
            imgData.setId(SeqUtil.getSeqNo(Constants.SEQ_NO_FOR_IMG_DATA_ID));
            imgData.setImgId(newImgId);
            imgData.setProgramId(oldImgData.getProgramId());
            imgData.setRuleId(oldImgData.getRuleId());
            imgData.setStatus(Constants.TABLE_RECORD_STATUS_NOMAL);
            imgData.setTenantId((String) fileInfo.get("tenantId"));
            imgData.setUpdateAccept((String) oprInfo.get("updateAccept"));
            imgData.setUpdateAuthor(authorId);
            imgData.setUpdateTime(updateTime);
            imgData.setUpdateType(Constants.UPDATE_TYPE_INSERT);
            imgData.setUserId(oldImgData.getUserId());

            imgDataList.add(imgData);
        }
        imgDataDao.saveAiImgDataBatch(imgDataList);
        imgDataDao.saveAiImgDataHisBatch(imgDataList);

        return outMap;
    }

    @Override
    @Transactional
    // 文件信息入表处理
    public Map<String, Object> saveFileInfo(Map<String, Object> mapIn) throws Exception {
        logger.info("saveFileInfo mapIn==" + mapIn);
        Map<String,Object> outMap = new HashMap<String,Object>();
        // 文件id
        String imgId = SeqUtil.getSeqNo(Constants.SEQ_NO_FOR_IMG_ID);

        // 解析原文件名，根据配置规则获取一些患者基本信息
        String birthday = (String) mapIn.get("birthday");
        String gender = (String) mapIn.get("gender");
        String userId = (String) mapIn.get("userId");

        // 文件信息入表
        AiImg imgVo = new AiImg();
        imgVo.setBirthday(birthday);
        imgVo.setClassId(Constants.DEFAULT_GROUP_NFFY_CLASSID);
        imgVo.setCreateAuthor((String)mapIn.get("author"));
        imgVo.setEquipId(Constants.DEFAULT_GROUP_NFFY_EQUIPID);
        imgVo.setFileAuthorName((String) mapIn.get("fileNameOld"));
        imgVo.setFileCreateTime((String) mapIn.get("fileCreateTime"));
        imgVo.setFileModifyTime((String) mapIn.get("fileModifyTime"));
        imgVo.setFileName((String) mapIn.get("fileName"));
        imgVo.setFilePath((String) mapIn.get("filePath"));
        imgVo.setFileSize((Long) mapIn.get("filesize"));
        imgVo.setFileType((String) mapIn.get("fileType"));
        imgVo.setGender(gender);
        imgVo.setHisNo((String) mapIn.get("hisNo"));
        imgVo.setId(imgId);
        imgVo.setInsideIp("");
        imgVo.setOpTime((String)mapIn.get("updateTime"));
        imgVo.setOutsideIp("");
        imgVo.setProgramId("");
        imgVo.setResidentAddress("");
        imgVo.setSourceFileId("");
        imgVo.setSourceFileName((String) mapIn.get("fileNameOld"));
        imgVo.setStatus(Constants.TABLE_RECORD_STATUS_NOMAL);
        imgVo.setTenantId((String) mapIn.get("tenantId"));
        imgVo.setUpdateAccept((String)mapIn.get("updateAccept"));
        imgVo.setUpdateAuthor((String)mapIn.get("authorName"));
        imgVo.setUpdateTime((String)mapIn.get("updateTime"));
        imgVo.setUploadType("01");
        imgVo.setUserId(userId);
        imgVo.setSourceFilePath("");
        imgVo.setFileUserName("");
        imgVo.setRotationAngle(0);
        imgVo.setSourceQueueId((String)mapIn.get("queueId"));
        imgDao.saveAiImg(imgVo);
        // 入文件历史表
        Map<String, Object> hisMap = new HashMap<String, Object>();
        hisMap.put("id", imgId);
        hisMap.put("updateTime", (String)mapIn.get("updateTime"));
        hisMap.put("updateAccept", (String)mapIn.get("updateAccept"));
        hisMap.put("updateType", Constants.UPDATE_TYPE_INSERT);
        imgDao.saveAiImgHis(hisMap);

        return outMap;
    }

    public void saveOpration(Map<String,Object> mapIn) throws Exception {
    	 // 操作记录
        String opUser = (String) mapIn.get("author");
        String opUsertype = "";
        if(!StringUtils.isBlank(opUser)) {
        	opUsertype = Constants.OPCODE_TYPE_DOCTOR;
        }

        Map<String, Object> paramRecord = new HashMap<String, Object>();
        Calendar now = Calendar.getInstance();
        paramRecord.put("month", String.valueOf(now.get(Calendar.MONTH) + 1));
        paramRecord.put("day", String.valueOf(now.get(Calendar.DAY_OF_MONTH)));
        paramRecord.put("userId", mapIn.get("userId"));
        paramRecord.put("queueId", "");
        paramRecord.put("opUser", opUser);
        paramRecord.put("opTime", (String)mapIn.get("updateTime"));
        paramRecord.put("remark", mapIn.get("opNote"));
        paramRecord.put("busiCategory", Constants.DOCTOR_ACTIVE_BUSI_TYPE_10);
        paramRecord.put("opUsertype", opUsertype);
        paramRecord.put("id", (String)mapIn.get("updateAccept"));
        paramRecord.put("opDesc", mapIn.get("opNote"));
        paramRecord.put("opCode", mapIn.get("opCode"));
        paramRecord.put("busiId", null);
        paramRecord.put("tenantId", (String) mapIn.get("tenantId"));
        paramRecord.put("opType", mapIn.get("opType"));
        paramRecord.put("taskId", "");
        paramRecord.put("breifIntro", mapIn.get("opNote"));
        iaOperationRecordDao.saveOperationRecord(paramRecord);
    }


    /**
	  * @author wuyz
	  * @time 2018-04-28
	  * 前端上传文件，将文件信息传入，后端只是入库操作，不做上传文件操作
	  *
	  **/
	@Override
	public Map<String, Object> saveWebImgInfo(Map<String, Object> mapIn) throws Exception {
		logger.info("saveWebImgInfo-service : " +mapIn);
		Map<String, Object> argMap = new HashMap<String, Object>(mapIn);
        Map<String, Object> outMap = new HashMap<String, Object>();
        Map<String, Object> oprInfo = ToolUtil.typeCast(argMap.get("oprInfo"));
        Map<String, Object> sessionInfo = ToolUtil.typeCast(mapIn.get("sessionInfo"));// 客户端上传无此节点
        Map<String, Object> userInfo = ToolUtil.typeCast(argMap.get("userInfo"));// 客户端上传无此节点
        String updateTime = (String) oprInfo.get("updateTime");
        String updateAccept = (String) oprInfo.get("updateAccept");
        String uploadType = (String) oprInfo.get("uploadType");

        // 上传文件
        outMap = this.saveMultiFileInfo(argMap);

        String opUser = "";
        String userId = "";
        String opUsertype = "";
        if (Constants.FILE_UPLOAD_TYPE_FOR_BACKGROUND_PROGRAM.equals(uploadType)) {
            opUser = Constants.BG_LOGIN_NO_ADMIN_FOR_IMG;
            opUsertype = Constants.OPCODE_TYPE_BG_ADMIN;
        }else if(Constants.FILE_UPLOAD_TYPE_FOR_USER.equals(uploadType)) {
        	opUser = (String) userInfo.get("userName");
            opUsertype = Constants.OPCODE_TYPE_PATIENT;
        }else if (MapUtils.isNotEmpty(sessionInfo)) {
            opUser = (String) sessionInfo.get("authorId");
            opUsertype = Constants.OPCODE_TYPE_DOCTOR;
        }
        if (MapUtils.isNotEmpty(userInfo)) {
            userId = (String) userInfo.get("userId");
        }
        // 操作记录
        Map<String, Object> paramRecord = new HashMap<String, Object>();
        Calendar now = Calendar.getInstance();
        paramRecord.put("month", String.valueOf(now.get(Calendar.MONTH) + 1));
        paramRecord.put("day", String.valueOf(now.get(Calendar.DAY_OF_MONTH)));
        paramRecord.put("userId", userId);
        paramRecord.put("queueId", "");
        paramRecord.put("opUser", opUser);
        paramRecord.put("opTime", updateTime);
        paramRecord.put("remark", oprInfo.get("opNote"));
        paramRecord.put("busiCategory", Constants.DOCTOR_ACTIVE_BUSI_TYPE_10);
        paramRecord.put("opUsertype", opUsertype);
        paramRecord.put("id", updateAccept);
        paramRecord.put("opDesc", oprInfo.get("opNote"));
        paramRecord.put("opCode", oprInfo.get("opCode"));
        paramRecord.put("busiId", null);
        paramRecord.put("tenantId", outMap.get("tenantId"));
        paramRecord.put("opType", oprInfo.get("opType"));
        paramRecord.put("taskId", "");
        outMap.remove("tenantId");
        paramRecord.put("breifIntro", outMap.toString());
        iaOperationRecordDao.saveOperationRecord(paramRecord);

        // 客户端小程序上传不返回数据
        if (Constants.FILE_UPLOAD_TYPE_FOR_BACKGROUND_PROGRAM.equals(uploadType)) {
            outMap.clear();
        }

        return outMap;
	}


	// 保存文件信息
    public Map<String, Object> saveMultiFileInfo(Map<String, Object> mapIn)
            throws Exception {
        Map<String, Object> argMap = new HashMap<String, Object>(mapIn);
        Map<String, Object> outMap = new HashMap<String, Object>();
        List<Map<String, Object>> fileList = ToolUtil.typeCast(argMap.get("fileList"));
        Map<String, Object> oprInfo = ToolUtil.typeCast(argMap.get("oprInfo"));
        String uploadType = (String) oprInfo.get("uploadType");

        // 逐个文件处理
        String uploadPath = "";
        String tenantId = "";
        List<Object> imgPathList = new ArrayList<Object>();
        Map<String, Object> uploadMapOut = new HashMap<String, Object>();
        argMap.remove("fileList");
        for(int i=0;i<fileList.size();i++) {
            // 根据小程序注册id校验小程序信息
            Map<String, Object> fileInfo = fileList.get(i);
            argMap.put("fileInfo", fileInfo);
            Map<String, Object> checkMapOut = this.checkEquipProgram(argMap);
            tenantId = (String) checkMapOut.get("tenantId");
            fileInfo.put("classId", (String) checkMapOut.get("classId"));
            fileInfo.put("tenantId", tenantId);
            fileInfo.put("equipId", (String) checkMapOut.get("equipId"));
            oprInfo.put("programId", (String) checkMapOut.get("programId"));

            // 文件上传路径：基础路径+租户id
            if (StringUtils.isBlank(uploadPath)) {
                uploadPath = ToolUtil.getUploadFilePath(Constants.FILE_UPLOAD_FOR_IMG_BASIC_PATH_ID_NAME, tenantId);
            }
            uploadMapOut.clear();
            // 入文件信息表
            Map<String, Object> saveMapOut = new HashMap<String, Object>();
            if (Constants.FILE_UPLOAD_TYPE_FOR_CLIP.equals(uploadType)) {
                saveMapOut = this.saveClipImgInfo(argMap);
            } else {
                saveMapOut = this.saveImgInfo(argMap);
            }
            imgPathList.add(saveMapOut);
        }
        outMap.put("imgList", imgPathList);
        outMap.put("tenantId", tenantId);

        return outMap;
    }

}
